package com.mxpioframework.security.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.hnichr.ump.common.service.AttachParseService;
import com.mxpioframework.common.vo.Result;

@Aspect
@Component
public class AttachAspect {

	@Autowired
	private AttachParseService attachParseService;

	// 定义切点Pointcut
	@Pointcut("execution(public * *..*.*Controller.*(..))")
	public void excudeService() {
	}

	@SuppressWarnings("rawtypes")
	@Around("excudeService()")
	public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
		Object result = pjp.proceed();
		if (result instanceof Result) {
			attachParseService.parseAttachResult((Result) result);
		}
		return result;
	}
}
